import request from '@/utils/request'

/* *
 * 获取角色列表
 */
export const getRolesList = () => request('roles')

/* *
 * 删除角色指定权限
 */
export const removeRolesRightsById = (roleId, rightId) =>
  request({
    method: 'DELETE',
    url: `roles/${roleId}/rights/${rightId}`
  })

/* *
 * 角色授权
 */
export const resetRolesRight = (roleId, rids) =>
  request({
    method: 'POST',
    url: `roles/${roleId}/rights`,
    data: {
      rids
    }
  })

/* *
 * 添加角色
 */
export const addRole = data =>
  request({
    method: 'POST',
    url: 'roles',
    data
  })

/* *
 * 编辑提交角色
 */
export const editRole = (id, data) =>
  request({
    method: 'PUT',
    url: `roles/${id}`,
    data
  })

/* *
 * 删除角色
 */
export const deleteRole = id =>
  request({
    method: 'DELETE',
    url: `roles/${id}`
  })
